<?php

class Remolque extends DBAbstractModel {

     public $placa_grua;
     public $empresa;
     public $estacionamiento;
     public $fecha;
     public $hora;
    
    function save() {
        $this->query = '';
        $this->query = "INSERT INTO remolques (placa_grua,empresa,estacionamiento,fecha,hora) VALUES ";
        $this->query.="('$this->placa_grua','$this->empresa','$this->estacionamiento','$this->fecha','$this->hora');";
        echo "query insertar: " . $this->query . "</br>";
        $this->execute_single_query();
    }
    function delete($key) {

        $this->query = '';
        $this->query = "DELETE FROM remolques WHERE placa_grua='$key'";
        echo "query eliminar: " . $this->query . "</br>";
        $this->execute_single_query();
    }
    
     function update($key) {
        $this->query = '';
        $this->query = "UPDATE  remolques SET placa_grua='$this->placa_grua',";
        $this->query.=" empresa='$this->empresa', estacionamiento='$this->estacionamiento', fecha='$this->fecha',";
        $this->query.=" hora='$this->hora' WHERE  placa_grua='$key'";
        
        echo "query actualizar: " . $this->query . "</br>";
        $this->execute_single_query();
    }
    
    function get($key) {
        if ($key != ''):
            $this->query = "SELECT *FROM remolques WHERE fecha = '$key'";
            $this->get_results_from_query();
        endif;
    }
    function getAll() {
        $this->query = "SELECT *FROM remolques";
        $this->get_results_from_query();
    }
}
?>
